package org.jks.service;

import java.util.List;

import org.jks.model.AssessAttachment;
import org.jks.model.User;
import org.springframework.stereotype.Service;

@Service
public class AssessAttachmentService extends EntityService<AssessAttachment> {
	public AssessAttachmentService() {
		MODEL_NAME = AssessAttachment.class.getSimpleName();
		CLASS_NAME = AssessAttachment.class;
	}
	
	public List<AssessAttachment> findAllByTime(String startTime, String endTime)
	{	 
		String hql = "from " + MODEL_NAME + " where attachment.AddTime >='" + startTime + "' and attachment.AddTime <='" + endTime + "'";
		List<AssessAttachment> temp = super.find(hql);
		if(temp == null || temp.size() == 0)
		{
			return null;
		}
		
		return temp;
	}
	
	public List<AssessAttachment> findAllByUserId(User user)
	{
		String hql = "from " + MODEL_NAME + " where User.Id =" + user.getId();
		List<AssessAttachment> temp = super.find(hql);
		if(temp == null || temp.size() == 0)
		{
			return null;
		}
		
		return temp;
	}
}
